<template>
    <view>
        <image :mode="mode" :src="img_src" :style="{width: '100%', height: '100%',display:'block'}" @error="imageError" @click="imgClick" />
    </view>
</template>

<script>
export default {
    props: {
        src: {
            type: String,
            default: '',
        },
        mode: {
            type: String,
            default: 'aspectFill',
        }
    },
    data() {
        return {
            img_src: ''
        };
    },
    watch: {
        src: {
            handler() {
                this.img_src = this.src
            },
            immediate: true,
            deep: true
        },
    },
    methods: {
        imageError() {
            this.img_src = '../../static/common/img_err.png';
        },
        imgClick() {
            this.$emit('imgClick');
        }
    },
};
</script>

<style lang="scss" scoped></style>
